// ChapterDTO.java
package com.example.teacherservice.dto;

import com.example.teacherservice.entity.Chapter;
import jdk.jshell.Snippet;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ChapterDTO {
    private Long id;
    private Long courseId;
    private Integer index;
    private String title;
    private String url;
    private Integer sortOrder;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;

    public ChapterDTO(Chapter chapter) {
        this.id = chapter.getId();
        this.courseId = chapter.getCourseId();  // 使用getCourseId()而非getCouId()
        this.index = chapter.getIndex();       // 使用getIndex()而非getChaIndex()
        this.title = chapter.getTitle();       // 使用getTitle()而非getChaTitle()
        this.url = chapter.getUrl();           // 使用getUrl()而非getChaUrl()
        this.sortOrder = chapter.getSortOrder();
        this.createTime = chapter.getCreateTime();
        this.updateTime = chapter.getUpdateTime();
    }

    // 新增构造方法（与convertToChapterDTO调用的字段完全匹配）
    public ChapterDTO(Long id, Long courseId, Integer index, String title, String url) {
        this.id = id;
        this.courseId = courseId;
        this.index = index;
        this.title = title;
        this.url = url;
    }
}